#include "gtest/gtest.h"

#include "Topic.h"
#include "SimpleAppender.h"


TEST(StreamTest, testSingle){
    auto tp = std::make_unique<Topic>("stream", ".");
    {
        auto appender = std::make_unique<SimpleAppender>(*tp);
        ASSERT_TRUE(appender->open());
        {
            const auto &[st, size] = appender->append("1");
            ASSERT_TRUE(st && size == 1+1);
        }
        {
            const auto &[st, size] = appender->append("2");
            ASSERT_TRUE(st && size == 1+1);
        }
        {
            const auto &[st, size] = appender->append("3");
            ASSERT_TRUE(st && size == 1+1);
        }
        ASSERT_TRUE(appender->commit());
        ASSERT_TRUE(appender->close());
    }
}

/*
TEST(StreamTest, testBatch){

    auto tp = std::make_unique<Topic>("stream-tp");

    auto appender = std::make_unique<Appender>(topic);

    auto batch = std::make_unique<Batch>();
    ret = appender.append(batch.add("").add("").add("")).commit(); //flush to file

    ASSERT_TRUE(bool(ret));
}*/
